package com.niit.cms.config;


import com.niit.cms.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description: 实现拦截器的注册
 * @Author: cao_jiaqi
 * @CreateTime： 2022/6/22 10:13
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * @Description: 注册拦截器
     * @Author: cao_jiaqi
     * @CreateTime: 2022/6/22 10:16
     * @param: registry
     **/
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(new LoginInterceptor());
        //  /** 代表所有路径，举例： /a, /a/b
        //  /user/*  只拦截 /user/b, /user  不拦截 /user/a/b
        registration.addPathPatterns("/**");
        //设置拦截白名单，这些请求不在拦截范围内
        registration.excludePathPatterns("/login", "/index", "/register", "/css/**", "/fonts/**", "/images/**", "/js/**", "/member.css/**");

    }
}
